import { App } from "vue";
import * as Pinia from "pinia";
import { createPersistedState } from "pinia-plugin-persistedstate";

const setupStore = (app: App) => {
  const pinia = Pinia.createPinia();
  const persist = createPersistedState({
    key: key => `${import.meta.env.VITE_STORAGE_PREFIX_NAME}_${key}`,
    storage: sessionStorage
  });
  pinia.use(persist);
  app.use(pinia);
};

export default setupStore;
